from BaseNN import nn
import numpy as np
model2 = nn('cls')
test_path = 'C:/Users/czeva/Desktop/20240527/test.csv'
test_x = np.loadtxt(test_path, dtype=float, delimiter=',',skiprows=0,usecols=range(0,52)) 
res = model2.inference(test_x, checkpoint="C:/Users/czeva/Desktop/20240527/basenn.pth")
model2.print_result(res)

test_y = np.loadtxt(test_path, dtype=float, delimiter=',',skiprows=0,usecols=52) 
# 定义一个计算分类正确率的函数
def cal_accuracy(y, pred_y):
    res = pred_y.argmax(axis=1)
    tp = np.array(y)==np.array(res)
    acc = np.sum(tp)/ y.shape[0]
    return acc

# 计算分类正确率
print("分类正确率为：",cal_accuracy(test_y, res))